package Hwork;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import cn.hutool.core.io.FileUtil;

public class RandomCallName3 {
	public static void main(String[] args) throws Exception {
		File file1=new File("Student3.txt");
		List<String> readLines = FileUtil.readLines(file1, "GBK");
		
		Random r = new Random();
		int nextInt = r.nextInt(readLines.size()); 
		ArrayList<String> list=new ArrayList<>();
		ArrayList<String> list1=new ArrayList<>();
		
		int n=1;
		
		File file2=new File("stucount.txt");
		BufferedReader brr = new BufferedReader(new FileReader(file2));
		String str;
		while ((str = brr.readLine()) != null) {
			n++;
		}
		list1.add(n+"张三");
		list.add(n+readLines.get(nextInt).split("-")[0]);
		if(n%3==0){
			FileUtil.appendLines(list1, file2, "GBK");
			System.out.println(list1.get(0));
		}else{
			FileUtil.appendLines(list, file2, "GBK");
			System.out.println(readLines.get(nextInt));
		}
		

		
		
		



	}
}
